package com.xnyzc.lhy.didi.controller.evaluation;

import com.xnyzc.lhy.common.component.didi.DiDiUrlConstant;
import com.xnyzc.lhy.common.entity.DiDiRv;
import com.xnyzc.lhy.common.exception.DiDiException;
import com.xnyzc.lhy.common.penum.EDiDiErrorCode;
import com.xnyzc.lhy.common.util.sign.AttestationTool;
import com.xnyzc.lhy.didi.entity.param.evaluation.EvaluationParam;
import com.xnyzc.lhy.didi.service.evaluation.EvaluationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 评价相关
 * </p>
 *
 * @author wangshuo
 * @since 2019-09-25
 */
@RestController
@RequestMapping("oa/didi/evaluation")
public class EvaluationController {

    @Autowired
    private EvaluationService evaluationService;

    /**
     * 乘客评价司机
     *
     * @param evaluationParam
     * @return
     */
    @ApiOperation(value = "乘客评价司机", notes = "乘客评价司机")
    @PostMapping(value = "/getPassengersEvaluation")
    public DiDiRv getPassengersEvaluation(@ApiParam(name =
            "evaluationParam", value = "乘客评价司机") EvaluationParam evaluationParam) {
        if (!AttestationTool.getRequestSign(evaluationParam, evaluationParam.getSign(), DiDiUrlConstant.didiSignReq)) {
            throw DiDiException.create(EDiDiErrorCode.failureOfVerification);
        }
        return evaluationService.getPassengersEvaluation(evaluationParam);
    }

}
